CC	      = gmcs
LIB       = ArtheaLib.dll
CONSOLE   = ArtheaConsole.exe
GUI	      = ArtheaGUI.exe
BIN_DIR	  = ../bin/
DOC_DIR	  = ../doc/
LIB_DIR	  = ../lib/

FLAGS	  = -define:MONO -win32icon:../../Arthea.ico

LIB_SRCS  = `find lib -name "*.cs"`
CONSOLE_SRCS = `find console -name "*.cs"`
GUI_SRCS  = `find GUI -name "*.cs"`

default:
	@echo "Options:"
	@echo " all     - build everything."
	@echo " lib     - build ${LIB}."
	@echo " console - build ${CONSOLE}."
	@echo " gui     - build ${GUI}."
	@echo " doc     - build documentation file."
	@echo " convert - convert source from windows to *nix."

all: lib console gui

.PHONY: console
console:
	${CC} ${FLAGS} -target:exe -r:${BIN_DIR}${LIB} -out:${BIN_DIR}${CONSOLE} ${CONSOLE_SRCS}

gui:
	${CC} ${FLAGS} -target:winexe -r:System.Windows.Forms.dll,${BIN_DIR}${LIB},System.Drawing.dll -out:${BIN_DIR}${GUI} ${GUI_SRCS}

.PHONY: lib
lib:
	${CC} ${FLAGS} -target:library -r:${BIN_DIR}ICSharpCode.SharpZipLib.dll,System.Data.dll -out:${BIN_DIR}${LIB} ${LIB_SRCS}

doc: lib
	if [ ! -d ${DOC_DIR} ]; then mkdir ${DOC_DIR}; fi
	monodocer -assembly:${BIN_DIR}${LIB} -path:${DOC_DIR}

convert:
	perl -pi -w -e 's/\255/ /g' ${LIB_SRCS} ${CONSOLE_SRCS} ${GUI_SRCS}
